<?php
//UMA
namespace App\Providers;

use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade;
use View;
use App\Models\InputItem;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
        $this->app->bind('App\Repositories\Interfaces\ScoreRepositoryInterface', 'App\Repositories\ScoreRepository');
        $this->app->bind('App\Repositories\Interfaces\MailRepositoryInterface', 'App\Repositories\MailRepository');
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Blade::component('components.rule_item', 'ruleitem');
        Validator::extend('kana', function ($attribute, $value, $parameters) {
//            mb_language("Ja");
//            mb_internal_encoding("utf-8");
//            return mb_convert_kana($value, "KC") == $value;
            return preg_match('/^([゠ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶヷヸヹヺ・ーヽヾヿ]+)$/u', $value);
        });

        View::composer('admin.historysearch', function($view){
            //$fields = ['nation', 'sex', 'hirement', 'marriage', 'year_of_birth', 'yearly_income', 'balance'];

            $datas = InputItem::with('options')->has('options')->get();
            $view->with('items', $datas);
        });
    }
}
